/**
 * 包含多个基于state的getter计算属性的对象
 */
export default {
    totalCount(state) {
        return state.cartFoods.reduce((preTotal, food) => {
            return (preTotal + food.count)
        }, 0)
    },
    totalPrice(state) {
        return state.cartFoods.reduce((preTotal, food) => {
            return (preTotal + food.count * food.price)
        }, 0)
    },
    positiveSize(state) {
        return state.ratings.reduce((preTotal, ratings) => {
            //rateType为0是满意，1是不满意，返回满意的有多少个
            return (preTotal + (ratings.rateType === 0 ? 1 : 0))
        }, 0)
    }
}